package com.fenyin.samples.study.quartz;  

import java.util.Date;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.quartz.Job;
import org.quartz.JobDataMap;
import org.quartz.JobDetail;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
  
public class ScanDirectoryJob implements Job{
	
	private static final Log logger = LogFactory.getLog(ScanDirectoryJob.class);

	public void execute(JobExecutionContext context) throws JobExecutionException {
		JobDetail jobDetail = context.getJobDetail();
		String jobName = jobDetail.getName();
		
		logger.info(jobName+" fire at "+new Date());
		
		JobDataMap dataMap = jobDetail.getJobDataMap();
		String dirName = dataMap.getString("SCAN_DIR");
		
		if(dirName == null){
			throw new JobExecutionException("scan directory is not configured!");
		}
		
		logger.info(dirName +" is scaning....");
	}

}
